//
// Created by sgyt on 2020/1/13.
// 自定义文件
#include <stdio.h>
#include <stdlib.h>
#define L_tmpnam 1024
#define MAXLINE 1024

int main(int argc,char *argv[])
{
    char name[L_tmpnam],line[MAXLINE];
    FILE *fp;

    printf("%s\n",tmpnam(NULL));

    //创建临时文件名称
    tmpnam(name);

    printf("%s\n",name);

    if((fp = tmpfile()) == NULL)
    {
        perror("tmpfile error\n");
    }

    fputs("one line of output\n",fp);

    rewind(fp);

    if(fgets(line, sizeof(line),fp) == NULL)
    {
        perror("fgets error\n");
    }

    fputs(line,stdout);
    return 0;
}

